import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/resources/assets.dart';
import 'package:bxultimate/widgets/mk_load_image.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart';

import 'controller.dart';

class MerchantEnterProductPage extends StatefulWidget {
  const MerchantEnterProductPage({Key? key}) : super(key: key);

  @override
  State<MerchantEnterProductPage> createState() =>
      _MerchantEnterProductPageState();
}

class _MerchantEnterProductPageState extends State<MerchantEnterProductPage> {
  final controller = Get.find<MerchantEnterProductController>();
  final state = Get.find<MerchantEnterProductController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
      child: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: AppBar(
          title: Text('商品'),
        ),
        body: EasyRefresh(
          child: ListView.builder(
              itemCount: 2,
              itemBuilder: (context, index) {
                return Container(
                  margin: EdgeInsets.symmetric(
                      vertical: 4, horizontal: AppTheme.iDefaultPadding),
                  padding: EdgeInsets.all(AppTheme.iDefaultPadding),
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(10)),
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      MkLoadImage(
                        Assets.imagesIcon,
                        width: 60,
                      ),
                      Gaps.hGap12,
                      Column(
                        mainAxisAlignment: MainAxisAlignment.end,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text('商品名称', style: TextStyle(fontSize: 16)),
                          Gaps.vGap12,
                          Row(
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: [
                              Text('￥100',style: TextStyle(fontSize: 18,color: Colors.redAccent),),
                              Gaps.hGap12,
                              Text('100',style: TextStyle(fontSize: 12,color: Colors.grey,decoration: TextDecoration.lineThrough,
                                decorationColor: const Color(0xff000000)),)
                            ],
                          )
                        ],
                      )
                    ],
                  ),
                );
              }),
        ),
        floatingActionButton: FloatingActionButton(
          elevation: 1,
          enableFeedback: true,
          backgroundColor: AppTheme.primaryColor,
          onPressed: () {},
          child: Icon(
            Icons.add,
            size: 40,
            color: Colors.white,
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<MerchantEnterProductController>();
    super.dispose();
  }
}
